﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using netDxf;
using netDxf.Blocks;
using netDxf.Collections;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Objects;
using netDxf.Tables;
using netDxf.Units;
using Attribute = netDxf.Entities.Attribute;
using Image = netDxf.Entities.Image;
using Point = netDxf.Entities.Point;
using Trace = netDxf.Entities.Trace;
using System.Threading;

namespace TestDxfDocument
{
    class SolidEndMills
    {
        public static void NoncentreCuttingEndMills(Dictionary<string, Object> data) //非中心刃立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            string path= Convert.ToString(data["path"]);
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double bhta = Convert.ToDouble(data["bhta"]) * pi / 180;
            string ccms = Convert.ToString(data["ccms"]); 
            double czc = Convert.ToDouble(data["czc"]);
            double db = Convert.ToDouble(data["db"]) * scale;
            double ds = Convert.ToDouble(data["ds"]) * scale;
            double TG = Convert.ToDouble(data["tg"]);
            if (ccms == "MKG")
            {
                if (czc == 0)
                {
                    db = 9.045 * scale;
                    ds = 6.4 * scale;
                    TG = 0.05205;
                }
                if (czc == 1)
                {
                    db = 12.065 * scale;
                    ds = 9.4 * scale;
                    TG = 0.04988;
                }
                if (czc == 2)
                {
                    db = 17.78 * scale;
                    ds = 14.6 * scale;
                    TG = 0.04995;
                }
                if (czc == 3)
                {
                    db = 23.825 * scale;
                    ds = 19.8 * scale;
                    TG = 0.05020;
                }
                if (czc == 4)
                {
                    db = 31.267 * scale;
                    ds = 25.9 * scale;
                    TG = 0.05194;
                }
                if (czc == 5)
                {
                    db = 44.399 * scale;
                    ds = 37.6 * scale;
                    TG = 0.05263;
                }
                if (czc == 6)
                {
                    db = 63.348 * scale;
                    ds = 53.9 * scale;
                    TG = 0.05214;
                }
            }
            if (ccms == "MEG")
            {
                TG = 0.05;
                if (czc == 4)
                {
                    db = 4 * scale;
                    ds = 2.9 * scale;
                }
                if (czc == 6)
                {
                    db = 6 * scale;
                    ds = 4.4 * scale;
                }
                if (czc == 80)
                {
                    db = 80 * scale;
                    ds = 70.2 * scale;
                }
                if (czc == 100)
                {
                    db = 100 * scale;
                    ds = 88.4 * scale;
                }
                if (czc == 120)
                {
                    db = 120 * scale;
                    ds = 106.6 * scale;
                }
                if (czc == 160)
                {
                    db = 160 * scale;
                    ds = 143 * scale;
                }
                if (czc == 200)
                {
                    db = 200 * scale;
                    ds = 179.4 * scale;
                }
            }
            double isframe = Convert.ToDouble(data["isframe"]);
            //坐标
            //主视图
            if (ccms == "ZYL")
            {
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v5 = new Vector2(v4.X, -oal + lh + (dconms - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v6 = new Vector2(dc / 2, -oal + lh);
                Vector2 v7 = new Vector2(v6.X, -oal + apmx);
                Vector2 v8 = new Vector2(v7.X, -oal);
                Vector2 v9 = new Vector2(dc / 4, -oal);
                Vector2 v10 = new Vector2(-v9.X, v9.Y);
                Vector2 v11 = new Vector2(-v8.X, v8.Y);
                Vector2 v12 = new Vector2(-v7.X, v7.Y);
                Vector2 v13 = new Vector2(-v6.X, v6.Y);
                Vector2 v14 = new Vector2(-v5.X, v5.Y);
                Vector2 v15 = new Vector2(-v4.X, v4.Y);
                Vector2 v16 = new Vector2(-v3.X, v3.Y);
                Vector2 v17 = new Vector2(-v2.X, v2.Y);
                Vector2 v18 = new Vector2(-v1.X, v1.Y);
                Vector2 v19 = new Vector2(0, 2);
                Vector2 v20 = new Vector2(0, -oal - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.5, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.5, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v11 };
                fun.drawBLine(dxf, Line10, 0.5, contour);
                Vector2[] Line11 = { v11, v12 };
                fun.drawBLine(dxf, Line11, 0.5, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v18 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v18, v1 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v19, v20 };
                fun.drawPlinetype(dxf, Line19, 0.15, centre, Linetype.Center);
                Vector2[] Line20 = { v17, v2 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v16, v3 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v15, v4 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v14, v5 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v13, v6 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v6, v8), offset * 2 + (v3.X + v6.X) / 2 - v7.X, 270, dimensionStyle);
                dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v11, v8), -offset, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v7, v8), offset + (v3.X + v6.X) / 2 - v7.X, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v7.X - (v3.X + v6.X) / 2, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                if (dconms >= dc)
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 3 + (v2.X - v8.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 3 + (v8.X - v2.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v17, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v15, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
            }
            if (ccms == "MKG" || ccms == "MEG")
            {
                ls = (db - ds) / TG;
                //坐标
                Vector2 v1 = new Vector2(ds / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(ds / 2 + Math.Sqrt(0.25 / (1 + TG * TG / 4)) * TG / 2, -Math.Sqrt(0.25 / (1 + TG * TG / 4)));
                Vector2 v3 = new Vector2(db / 2, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - v3.X + dn / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + lh + (dconms - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v6 = new Vector2(dc / 2, -oal + lh);
                Vector2 v7 = new Vector2(v6.X, -oal + apmx);
                Vector2 v8 = new Vector2(v7.X, -oal);
                Vector2 v9 = new Vector2(dc / 4, -oal);
                Vector2 v10 = new Vector2(-v9.X, v9.Y);
                Vector2 v11 = new Vector2(-v8.X, v8.Y);
                Vector2 v12 = new Vector2(-v7.X, v7.Y);
                Vector2 v13 = new Vector2(-v6.X, v6.Y);
                Vector2 v14 = new Vector2(-v5.X, v5.Y);
                Vector2 v15 = new Vector2(-v4.X, v4.Y);
                Vector2 v16 = new Vector2(-v3.X, v3.Y);
                Vector2 v17 = new Vector2(-v2.X, v2.Y);
                Vector2 v18 = new Vector2(-v1.X, v1.Y);
                Vector2 v19 = new Vector2(0, 2);
                Vector2 v20 = new Vector2(0, -oal - 2);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v3));
                Arc1.Vertexes.Add(new LwPolylineVertex(v4));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                LwPolyline Arc2 = new LwPolyline();
                Arc2.Vertexes.Add(new LwPolylineVertex(v15));
                Arc2.Vertexes.Add(new LwPolylineVertex(v16));
                Arc2.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc2, 0.3, contour);
                Vector2[] Line3 = { v4, v5 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v5, v6 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v6, v7 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v7, v8 };
                fun.drawBLine(dxf, Line6, 0.5, contour);
                Vector2[] Line7 = { v8, v9 };
                fun.drawBLine(dxf, Line7, 0.5, contour);
                Vector2[] Line8 = { v9, v10 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v10, v11 };
                fun.drawBLine(dxf, Line9, 0.5, contour);
                Vector2[] Line10 = { v11, v12 };
                fun.drawBLine(dxf, Line10, 0.5, contour);
                Vector2[] Line11 = { v12, v13 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v13, v14 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v14, v15 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line15 = { v16, v17 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v17, v18 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v18, v1 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v17, v2 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v16, v3 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v15, v4 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v14, v5 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v13, v6 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v19, v20 };
                fun.drawPlinetype(dxf, Line23, 0.15, centre, Linetype.Center);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v6, v8), offset * 2 + (v3.X + v6.X) / 2 - v7.X, 270, dimensionStyle);
                dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v11, v8), -offset, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v7, v8), offset + (v3.X + v6.X) / 2 - v7.X, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸5
                if (dconms >= dc)
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 3 + (v2.X - v8.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 3 + (v8.X - v2.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v15, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void CentreCuttingEndMill(Dictionary<string, Object> data) //中心刃立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            string path = Convert.ToString(data["path"]);
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double bhta = Convert.ToDouble(data["bhta"]) * pi / 180;
            string ccms = Convert.ToString(data["ccms"]);
            double czc = Convert.ToDouble(data["czc"]);
            double db = Convert.ToDouble(data["db"]) * scale;
            double ds = Convert.ToDouble(data["ds"]) * scale;
            double tg = Convert.ToDouble(data["tg"]);
            if (ccms == "MKG")
            {
                if (czc == 0)
                {
                    db = 9.045 * scale;
                    ds = 6.4 * scale;
                    tg = 0.05205;
                }
                if (czc == 1)
                {
                    db = 12.065 * scale;
                    ds = 9.4 * scale;
                    tg = 0.04988;
                }
                if (czc == 2)
                {
                    db = 17.78 * scale;
                    ds = 14.6 * scale;
                    tg = 0.04995;
                }
                if (czc == 3)
                {
                    db = 23.825 * scale;
                    ds = 19.8 * scale;
                    tg = 0.05020;
                }
                if (czc == 4)
                {
                    db = 31.267 * scale;
                    ds = 25.9 * scale;
                    tg = 0.05194;
                }
                if (czc == 5)
                {
                    db = 44.399 * scale;
                    ds = 37.6 * scale;
                    tg = 0.05263;
                }
                if (czc == 6)
                {
                    db = 63.348 * scale;
                    ds = 53.9 * scale;
                    tg = 0.05214;
                }
            }
            if (ccms == "MEG")
            {
                tg = 0.05;
                if (czc == 4)
                {
                    db = 4 * scale;
                    ds = 2.9 * scale;
                }
                if (czc == 6)
                {
                    db = 6 * scale;
                    ds = 4.4 * scale;
                }
                if (czc == 80)
                {
                    db = 80 * scale;
                    ds = 70.2 * scale;
                }
                if (czc == 100)
                {
                    db = 100 * scale;
                    ds = 88.4 * scale;
                }
                if (czc == 120)
                {
                    db = 120 * scale;
                    ds = 106.6 * scale;
                }
                if (czc == 160)
                {
                    db = 160 * scale;
                    ds = 143 * scale;
                }
                if (czc == 200)
                {
                    db = 200 * scale;
                    ds = 179.4 * scale;
                }
            }
            double isframe = Convert.ToDouble(data["isframe"]);
            //坐标
            //主视图
            if (ccms == "ZYL")
            {
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v5 = new Vector2(v4.X, -oal + lh + (dconms - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v6 = new Vector2(dc / 2, -oal + lh);
                Vector2 v7 = new Vector2(v6.X, -oal + apmx);
                Vector2 v8 = new Vector2(v7.X, -oal);
                Vector2 v11 = new Vector2(-v8.X, v8.Y);
                Vector2 v12 = new Vector2(-v7.X, v7.Y);
                Vector2 v13 = new Vector2(-v6.X, v6.Y);
                Vector2 v14 = new Vector2(-v5.X, v5.Y);
                Vector2 v15 = new Vector2(-v4.X, v4.Y);
                Vector2 v16 = new Vector2(-v3.X, v3.Y);
                Vector2 v17 = new Vector2(-v2.X, v2.Y);
                Vector2 v18 = new Vector2(-v1.X, v1.Y);
                Vector2 v19 = new Vector2(0, 2);
                Vector2 v20 = new Vector2(0, -oal - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.5, contour);
                Vector2[] Line8 = { v8, v11 };
                fun.drawBLine(dxf, Line8, 0.5, contour);
                Vector2[] Line11 = { v11, v12 };
                fun.drawBLine(dxf, Line11, 0.5, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v18 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v18, v1 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v19, v20 };
                fun.drawPlinetype(dxf, Line19, 0.15, centre, Linetype.Center);
                Vector2[] Line20 = { v17, v2 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v16, v3 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v15, v4 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v14, v5 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v13, v6 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v6, v8), offset * 2 + (v3.X + v6.X) / 2 - v7.X, 270, dimensionStyle);
                dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v11, v8), -offset, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v7, v8), offset + (v3.X + v6.X) / 2 - v7.X, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v7.X - (v3.X + v6.X) / 2, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                if (dconms >= dc)
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 3 + (v2.X - v8.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 3 + (v8.X - v2.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v17, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v15, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
            }
            if (ccms == "MKG" || ccms == "MEG")
            {
                ls = (db - ds) / tg;
                //坐标
                Vector2 v1 = new Vector2(ds / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(ds / 2 + Math.Sqrt(0.25 / (1 + tg * tg / 4)) * tg / 2, -Math.Sqrt(0.25 / (1 + tg * tg / 4)));
                Vector2 v3 = new Vector2(db / 2, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - v3.X + dn / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + lh + (dconms - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v6 = new Vector2(dc / 2, -oal + lh);
                Vector2 v7 = new Vector2(v6.X, -oal + apmx);
                Vector2 v8 = new Vector2(v7.X, -oal);
                Vector2 v11 = new Vector2(-v8.X, v8.Y);
                Vector2 v12 = new Vector2(-v7.X, v7.Y);
                Vector2 v13 = new Vector2(-v6.X, v6.Y);
                Vector2 v14 = new Vector2(-v5.X, v5.Y);
                Vector2 v15 = new Vector2(-v4.X, v4.Y);
                Vector2 v16 = new Vector2(-v3.X, v3.Y);
                Vector2 v17 = new Vector2(-v2.X, v2.Y);
                Vector2 v18 = new Vector2(-v1.X, v1.Y);
                Vector2 v19 = new Vector2(0, 2);
                Vector2 v20 = new Vector2(0, -oal - 2);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v3));
                Arc1.Vertexes.Add(new LwPolylineVertex(v4));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                LwPolyline Arc2 = new LwPolyline();
                Arc2.Vertexes.Add(new LwPolylineVertex(v15));
                Arc2.Vertexes.Add(new LwPolylineVertex(v16));
                Arc2.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc2, 0.3, contour);
                Vector2[] Line3 = { v4, v5 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v5, v6 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v6, v7 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v7, v8 };
                fun.drawBLine(dxf, Line6, 0.5, contour);
                Vector2[] Line7 = { v8, v11 };
                fun.drawBLine(dxf, Line7, 0.5, contour);
                Vector2[] Line10 = { v11, v12 };
                fun.drawBLine(dxf, Line10, 0.5, contour);
                Vector2[] Line11 = { v12, v13 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v13, v14 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v14, v15 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line15 = { v16, v17 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v17, v18 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v18, v1 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v17, v2 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v16, v3 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v15, v4 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v14, v5 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v13, v6 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v19, v20 };
                fun.drawPlinetype(dxf, Line23, 0.15, centre, Linetype.Center);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v6, v8), offset * 2 + (v3.X + v6.X) / 2 - v7.X, 270, dimensionStyle);
                dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v11, v8), -offset, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v7, v8), offset + (v3.X + v6.X) / 2 - v7.X, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸5
                if (dconms >= dc)
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 3 + (v2.X - v8.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 3 + (v8.X - v2.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v15, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void AngularEndMill(Dictionary<string, Object> data) //直柄锥度铣刀
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            string path = Convert.ToString(data["path"]);
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double kapr = Convert.ToDouble(data["kapr"]) * pi / 180;
            double dcx = apmx / Math.Tan(kapr) * 2 + dc;
            double isframe = Convert.ToDouble(data["isframe"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
            Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
            Vector2 v3 = new Vector2(v2.X, -ls);
            Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
            Vector2 v5 = new Vector2(v4.X, -oal + apmx + (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
            Vector2 v6 = new Vector2(v3.X, -oal + apmx);
            Vector2 v7 = new Vector2(dcx / 2, v6.Y);
            Vector2 v8 = new Vector2(dc / 2, -oal);
            Vector2 v9 = new Vector2(dc / 4, -oal);
            Vector2 v10 = new Vector2(-v9.X, v9.Y);
            Vector2 v11 = new Vector2(-v8.X, v8.Y);
            Vector2 v12 = new Vector2(-v7.X, v7.Y);
            Vector2 v13 = new Vector2(-v6.X, v6.Y);
            Vector2 v14 = new Vector2(-v5.X, v5.Y);
            Vector2 v15 = new Vector2(-v4.X, v4.Y);
            Vector2 v16 = new Vector2(-v3.X, v3.Y);
            Vector2 v17 = new Vector2(-v2.X, v2.Y);
            Vector2 v18 = new Vector2(-v1.X, v1.Y);
            Vector2 v19 = new Vector2(0, 2);
            Vector2 v20 = new Vector2(0, -oal - 2);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.5, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.5, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawBLine(dxf, Line10, 0.5, contour);
            Vector2[] Line11 = { v11, v12 };
            fun.drawBLine(dxf, Line11, 0.5, contour);
            Vector2[] Line12 = { v12, v13 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, v17 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v17, v18 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v18, v1 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v19, v20 };
            fun.drawPlinetype(dxf, Line19, 0.15, centre, Linetype.Center);
            Vector2[] Line20 = { v17, v2 };
            fun.drawBLine(dxf, Line20, 0.3, contour);
            Vector2[] Line21 = { v16, v3 };
            fun.drawBLine(dxf, Line21, 0.3, contour);
            Vector2[] Line22 = { v15, v4 };
            fun.drawBLine(dxf, Line22, 0.3, contour);
            Vector2[] Line23 = { v14, v5 };
            fun.drawBLine(dxf, Line23, 0.3, contour);
            Vector2[] Line24 = { v13, v6 };
            fun.drawBLine(dxf, Line24, 0.3, contour);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v12, v7), -offset * 2 - apmx, 0, dimensionStyle);
            dim1.UserText = "DCX = " + Math.Round(dcx / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v11, v8), -offset, 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v7, v8), offset + (v7.X - v8.X) / 2, 270, dimensionStyle);
            dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v7.X - v3.X, 270, dimensionStyle);
            dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 2 + 0.25 + v7.X - (v3.X + v8.X) / 2, 270, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v17, v2), offset + 0.5, 0, dimensionStyle);
            dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            Angular2LineDimension angdim7 = new Angular2LineDimension(new Line(v8, v7), new Line(v8, new Vector2(v7.X, v8.Y)), (v7.X - v8.X) / 2, dimensionStyle);
            angdim7.UserText = "KAPR = " + Math.Round(kapr / (pi / 180), 2) + "°";
            dxf.AddEntity(angdim7);
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v15, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
            dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
            dxf.AddEntity(dim8);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void DovetailEndMill(Dictionary<string, Object> data) //直柄燕尾槽铣刀
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            string path = Convert.ToString(data["path"]);
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double kapr = Convert.ToDouble(data["kapr"]) * pi / 180;
            double dcx = dc - apmx / Math.Tan(pi - kapr) * 2;
            double isframe = Convert.ToDouble(data["isframe"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
            Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
            Vector2 v3 = new Vector2(v2.X, -ls);
            Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
            Vector2 v5 = new Vector2(v4.X, -oal + apmx + (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
            Vector2 v6 = new Vector2(v3.X, -oal + apmx);
            Vector2 v7 = new Vector2(dcx / 2, v6.Y);
            Vector2 v8 = new Vector2(dc / 2, -oal);
            Vector2 v9 = new Vector2(dc / 4, -oal);
            Vector2 v10 = new Vector2(-v9.X, v9.Y);
            Vector2 v11 = new Vector2(-v8.X, v8.Y);
            Vector2 v12 = new Vector2(-v7.X, v7.Y);
            Vector2 v13 = new Vector2(-v6.X, v6.Y);
            Vector2 v14 = new Vector2(-v5.X, v5.Y);
            Vector2 v15 = new Vector2(-v4.X, v4.Y);
            Vector2 v16 = new Vector2(-v3.X, v3.Y);
            Vector2 v17 = new Vector2(-v2.X, v2.Y);
            Vector2 v18 = new Vector2(-v1.X, v1.Y);
            Vector2 v19 = new Vector2(0, 2);
            Vector2 v20 = new Vector2(0, -oal - 2);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.5, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.5, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawBLine(dxf, Line10, 0.5, contour);
            Vector2[] Line11 = { v11, v12 };
            fun.drawBLine(dxf, Line11, 0.5, contour);
            Vector2[] Line12 = { v12, v13 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, v17 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v17, v18 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v18, v1 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v19, v20 };
            fun.drawPlinetype(dxf, Line19, 0.15, centre, Linetype.Center);
            Vector2[] Line20 = { v17, v2 };
            fun.drawBLine(dxf, Line20, 0.3, contour);
            Vector2[] Line21 = { v16, v3 };
            fun.drawBLine(dxf, Line21, 0.3, contour);
            Vector2[] Line22 = { v15, v4 };
            fun.drawBLine(dxf, Line22, 0.3, contour);
            Vector2[] Line23 = { v14, v5 };
            fun.drawBLine(dxf, Line23, 0.3, contour);
            Vector2[] Line24 = { v13, v6 };
            fun.drawBLine(dxf, Line24, 0.3, contour);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v12, v7), -offset - apmx, 0, dimensionStyle);
            dim1.UserText = "DCX = " + Math.Round(dcx / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v11, v8), -offset * 2, 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v7, v8), offset + (v8.X - v7.X) / 2, 270, dimensionStyle);
            dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v8.X - v3.X, 270, dimensionStyle);
            dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 2 + 0.25 + (v8.X - (v3.X + v7.X) / 2) / 2, 270, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v17, v2), offset + 0.5, 0, dimensionStyle);
            dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            Angular2LineDimension angdim7 = new Angular2LineDimension(new Line(v8, v7), new Line(v8, new Vector2(v8.X * 2 - v7.X, v8.Y)), offset / 2, dimensionStyle);
            angdim7.UserText = "KAPR = " + Math.Round(kapr / (pi / 180), 2) + "°";
            dxf.AddEntity(angdim7);
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v15, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
            dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
            dxf.AddEntity(dim8);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void SolidTslotEndMill(Dictionary<string, Object> data) //直柄T型槽立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层

            //作图
            //参数
            string path = Convert.ToString(data["path"]);
            double soal = 1;
            //double scale = Convert.ToDouble(data["scale"]); //放大系数
            double scale = 1; //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            /*double dc = Convert.ToDouble(data["dc"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double lh = oal - ls - (dconms - dn) / 2;
            double isframe = Convert.ToDouble(data["isframe"]);*/

            double dc = 60 * scale;
            double dconms = 10 * scale;
            double oal = 120 * scale;
            double ls = 35 * scale;
            double apmx = 20 * scale;
            double dn = 8 * scale;
            double lh = oal - ls - (dconms - dn) / 2;
            double isframe = 0;


            //坐标
            //主视图
            Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
            Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
            Vector2 v3 = new Vector2(v2.X, -ls);
            Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
            Vector2 v5 = new Vector2(v4.X, -oal + apmx + (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
            Vector2 v6 = new Vector2(v3.X, -oal + apmx);
            Vector2 v8 = new Vector2(dc / 2, v6.Y);
            Vector2 v7 = new Vector2((v8.X + v6.X) / 2, v6.Y);
            Vector2 v9 = new Vector2(dc / 2, -oal);
            Vector2 v10 = new Vector2(dc / 4, -oal);
            Vector2 v11 = new Vector2(-v10.X, v10.Y);
            Vector2 v12 = new Vector2(-v9.X, v9.Y);
            Vector2 v13 = new Vector2(-v8.X, v8.Y);
            Vector2 v14 = new Vector2(-v7.X, v7.Y);
            Vector2 v15 = new Vector2(-v6.X, v6.Y);
            Vector2 v16 = new Vector2(-v5.X, v5.Y);
            Vector2 v17 = new Vector2(-v4.X, v4.Y);
            Vector2 v18 = new Vector2(-v3.X, v3.Y);
            Vector2 v19 = new Vector2(-v2.X, v2.Y);
            Vector2 v20 = new Vector2(-v1.X, v1.Y);
            Vector2 v21 = new Vector2(0, 2);
            Vector2 v22 = new Vector2(0, -oal - 2);

            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.5, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.5, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.5, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v11, v12 };
            fun.drawBLine(dxf, Line11, 0.5, contour);
            Vector2[] Line12 = { v12, v13 };
            fun.drawBLine(dxf, Line12, 0.5, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.5, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, v17 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v17, v18 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v18, v19 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v19, v20 };
            fun.drawBLine(dxf, Line19, 0.3, contour);
            Vector2[] Line20 = { v20, v1 };
            fun.drawBLine(dxf, Line20, 0.3, contour);
            Vector2[] Line21 = { v21, v22 };
            fun.drawPlinetype(dxf, Line21, 0.15, centre, Linetype.Center);
            Vector2[] Line22 = { v19, v2 };
            fun.drawBLine(dxf, Line22, 0.3, contour);
            Vector2[] Line23 = { v18, v3 };
            fun.drawBLine(dxf, Line23, 0.3, contour);
            Vector2[] Line24 = { v17, v4 };
            fun.drawBLine(dxf, Line24, 0.3, contour);
            Vector2[] Line25 = { v16, v5 };
            fun.drawBLine(dxf, Line25, 0.3, contour);
            Vector2[] Line26 = { v15, v6 };
            fun.drawBLine(dxf, Line26, 0.3, contour);

            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;

            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;

            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v4, v9), offset * 2 + (v9.X - v4.X) / 2, 270, dimensionStyle);
            dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v12, v9), -offset, 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v8, v9), offset, 270, dimensionStyle);
            dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v8.X - v3.X, 270, dimensionStyle);
            dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v9, v1), offset * 3 + 0.25 + v9.X - (v3.X + v9.X) / 2, 270, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v19, v2), offset + 0.5, 0, dimensionStyle);
            dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            LinearDimension dim7 = new LinearDimension(new Line(v17, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
            dim7.UserText = "DN = " + Math.Round(dn / scale, 2);
            dxf.AddEntity(dim7);

            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void BallnosedEndMill(Dictionary<string, Object> data) //直柄球头立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            string path = Convert.ToString(data["path"]);
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double prfrad = Convert.ToDouble(data["prfrad"]) * scale;
            double h = prfrad - Math.Sqrt(prfrad * prfrad - dc * dc / 4);
            double isframe = Convert.ToDouble(data["isframe"]);

            //坐标
            //主视图
            Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
            Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
            Vector2 v3 = new Vector2(v2.X, -ls);
            Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
            Vector2 v5 = new Vector2(v4.X, -oal + lh + (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
            Vector2 v6 = new Vector2(dc / 2, -oal + lh);
            Vector2 v7 = new Vector2(v6.X, -oal + apmx);
            Vector2 v8 = new Vector2(v7.X, -oal + prfrad - Math.Sqrt(prfrad * prfrad - dc * dc / 4));
            Vector2 v9 = new Vector2(-v8.X, v8.Y);
            Vector2 v10 = new Vector2(-v7.X, v7.Y);
            Vector2 v11 = new Vector2(-v6.X, v6.Y);
            Vector2 v12 = new Vector2(-v5.X, v5.Y);
            Vector2 v13 = new Vector2(-v4.X, v4.Y);
            Vector2 v14 = new Vector2(-v3.X, v3.Y);
            Vector2 v15 = new Vector2(-v2.X, v2.Y);
            Vector2 v16 = new Vector2(-v1.X, v1.Y);
            Vector2 v17 = new Vector2(0, 2);
            Vector2 v18 = new Vector2(0, -oal - 2);

            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.5, contour);
            LwPolyline Arc8 = new LwPolyline();
            Arc8.Vertexes.Add(new LwPolylineVertex(v9));
            Arc8.Vertexes.Add(new LwPolylineVertex(v8));
            Arc8.Vertexes[0].Bulge = (prfrad - Math.Sqrt(prfrad * prfrad - dc * dc / 4)) * 2 / dc;
            fun.PolyFill(dxf, Arc8, 0.5, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.5, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v11, v12 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v12, v13 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, v1 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v15, v2 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v14, v3 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v13, v4 };
            fun.drawBLine(dxf, Line19, 0.3, contour);
            Vector2[] Line20 = { v12, v5 };
            fun.drawBLine(dxf, Line20, 0.3, contour);
            Vector2[] Line21 = { v17, v18 };
            fun.drawPlinetype(dxf, Line21, 0.15, center, Linetype.Center);
            Vector2[] Line22 = { v11, v6 };
            fun.drawBLine(dxf, Line22, 0.3, contour);
            if (prfrad * 2 != dc)
            {
                Vector2[] Line23 = { v9, v8 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
            }
            Arc arc8 = new Arc(new Vector2(0, -oal + prfrad), prfrad, -(pi - Math.Atan((prfrad - h) / v8.X)) / pi * 180, -Math.Atan((prfrad - h) / v8.X) / pi * 180);

            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;

            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;

            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v6, new Vector2(0, -oal)), offset * 2 + dc / 4, 270, dimensionStyle);
            dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v8, v9), -offset - (prfrad - Math.Sqrt(prfrad * prfrad - dc * dc / 4)), 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v7, new Vector2(0, -oal)), offset + dc / 4, 270, dimensionStyle);
            dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v7.X - v3.X, 270, dimensionStyle);
            dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v1, new Vector2(0, -oal)), offset * 3 + 0.5 + v1.X / 2 + v7.X - v2.X, 270, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v15, v2), offset + 0.5, 0, dimensionStyle);
            dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            LinearDimension dim7 = new LinearDimension(new Line(v13, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
            dim7.UserText = "DN = " + Math.Round(dn / scale, 2);
            dxf.AddEntity(dim7);
            //尺寸8
            RadialDimension dimrad8 = new RadialDimension(arc8, -100, offset, dimensionStyle);//DimensionStyle.Default);
            dimrad8.UserText = "PRFRAD = " + Math.Round(prfrad / scale, 2);
            dxf.AddEntity(dimrad8);

            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void DieEndMill(Dictionary<string, Object> data) //直柄锥度球头立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //作图
            //参数
            string path = Convert.ToString(data["path"]);
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double prfa = Convert.ToDouble(data["prfa"]) * pi / 180;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double prfrad = Convert.ToDouble(data["prfrad"]) * scale;
            double dcx = dc + (apmx - prfrad + Math.Sqrt(prfrad * prfrad - dc * dc / 4)) * 2 * Math.Tan(prfa / 2);
            double isframe = Convert.ToDouble(data["isframe"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
            Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
            Vector2 v3 = new Vector2(v2.X, -ls);
            Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
            Vector2 v5 = new Vector2(v4.X, -oal + lh + (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
            Vector2 v6 = new Vector2(bd / 2, -oal + lh);
            Vector2 v7 = new Vector2(v6.X, -oal + apmx);
            Vector2 v8 = new Vector2(dcx / 2, v7.Y);
            Vector2 v9 = new Vector2(dc / 2, -oal + prfrad - Math.Sqrt(prfrad * prfrad - dc * dc / 4));
            Vector2 v10 = new Vector2(-v9.X, v9.Y);
            Vector2 v11 = new Vector2(-v8.X, v8.Y);
            Vector2 v12 = new Vector2(-v7.X, v7.Y);
            Vector2 v13 = new Vector2(-v6.X, v6.Y);
            Vector2 v14 = new Vector2(-v5.X, v5.Y);
            Vector2 v15 = new Vector2(-v4.X, v4.Y);
            Vector2 v16 = new Vector2(-v3.X, v3.Y);
            Vector2 v17 = new Vector2(-v2.X, v2.Y);
            Vector2 v18 = new Vector2(-v1.X, v1.Y);
            Vector2 v19 = new Vector2(0, 2);
            Vector2 v20 = new Vector2(0, -oal - 2);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.5, contour);
            LwPolyline Arc9 = new LwPolyline();
            Arc9.Vertexes.Add(new LwPolylineVertex(v10));
            Arc9.Vertexes.Add(new LwPolylineVertex(v9));
            Arc9.Vertexes[0].Bulge = (prfrad - Math.Sqrt(prfrad * prfrad - dc * dc / 4)) * 2 / dc;
            fun.PolyFill(dxf, Arc9, 0.5, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawBLine(dxf, Line10, 0.5, contour);
            Vector2[] Line11 = { v11, v12 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v12, v13 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, v17 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v17, v18 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v18, v1 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v17, v2 };
            fun.drawBLine(dxf, Line19, 0.3, contour);
            Vector2[] Line20 = { v16, v3 };
            fun.drawBLine(dxf, Line20, 0.3, contour);
            Vector2[] Line21 = { v15, v4 };
            fun.drawBLine(dxf, Line21, 0.3, contour);
            Vector2[] Line22 = { v14, v5 };
            fun.drawBLine(dxf, Line22, 0.3, contour);
            Vector2[] Line23 = { v13, v6 };
            fun.drawBLine(dxf, Line23, 0.3, contour);
            Vector2[] Line24 = { v19, v20 };
            fun.drawPlinetype(dxf, Line24, 0.15, center, Linetype.Center);
            Vector2[] Line25 = { v11, v8 };
            fun.drawBLine(dxf, Line25, 0.3, contour);
            if (prfrad * 2 != dc)
            {
                Vector2[] Line26 = { v10, v9 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
            }
            Arc arc9 = new Arc(new Vector2(0, -oal + prfrad), prfrad, -(pi - prfa / 2) / pi * 180, -prfa / 2 / pi * 180);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v6, new Vector2(0, -oal)), offset * 2 + bd / 4, 270, dimensionStyle);
            dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v9, v10), -offset - (prfrad - Math.Sqrt(prfrad * prfrad - dc * dc / 4)), 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v7, new Vector2(0, -oal)), offset + bd / 4, 270, dimensionStyle);
            dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v7.X - v3.X, 270, dimensionStyle);
            dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v1, new Vector2(0, -oal)), offset * 3 + 0.5 + v1.X / 2 + v7.X - v2.X, 270, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v17, v2), offset + 0.5, 0, dimensionStyle);
            dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            LinearDimension dim7 = new LinearDimension(new Line(v15, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
            dim7.UserText = "DN = " + Math.Round(dn / scale, 2);
            dxf.AddEntity(dim7);
            //尺寸8
            if (dcx != bd)
            {
                LinearDimension dim8 = new LinearDimension(new Line(v11, v8), -offset * 2 - v8.Y - oal, 0, dimensionStyle);
                dim8.UserText = "DCX = " + Math.Round(dcx / scale, 2);
                dxf.AddEntity(dim8);
            }
            //尺寸9
            if (dcx != bd)
            {
                LinearDimension dim9 = new LinearDimension(new Line(v12, v7), -offset * 3 - v8.Y - oal, 0, dimensionStyle);
                dim9.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim9);
            }
            //尺寸10
            if (dcx == bd)
            {
                LinearDimension dim10 = new LinearDimension(new Line(v11, v8), -offset * 2 - v8.Y - oal, 0, dimensionStyle);
                dim10.UserText = "DCX.BD = " + Math.Round(dcx / scale, 2);
                dxf.AddEntity(dim10);
            }
            //尺寸11
            RadialDimension dimrad11 = new RadialDimension(arc9, -100, offset, dimensionStyle);//DimensionStyle.Default);
            dimrad11.UserText = "PRFRAD = " + Math.Round(prfrad / scale, 2);
            dxf.AddEntity(dimrad11);
            //尺寸12
            Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v10, v11), new Line(v9, v8), dcx / 2 / Math.Tan(prfa / 2) - 5, dimensionStyle);
            angdim12.UserText = "PRFA = " + Math.Round(prfa / (pi / 180), 2) + "°";
            dxf.AddEntity(angdim12);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void ConcaveRoundedProfileEndMill(Dictionary<string, Object> data)  //凹半圆立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            string path = Convert.ToString(data["path"]);
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcx = Convert.ToDouble(data["dcx"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double prfrad = Convert.ToDouble(data["prfrad"]) * scale;
            double l = Math.Sqrt((dcx - dc) * (dcx - dc) / 4 + apmx * apmx);
            double h = prfrad - Math.Sqrt(prfrad * prfrad - l * l / 4);
            double a1 = Math.Atan(l / 2 / (prfrad - h));
            double a2 = Math.Atan(apmx / (dcx - dc) * 2);
            double isframe = Convert.ToDouble(data["isframe"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
            Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
            Vector2 v3 = new Vector2(v2.X, -ls);
            Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
            Vector2 v5 = new Vector2(v4.X, -oal + lh + (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
            Vector2 v6 = new Vector2(v3.X, -oal + lh);
            Vector2 v7 = new Vector2(dcx / 2, v6.Y);
            Vector2 v8 = new Vector2(v7.X, -oal + apmx);
            Vector2 v9 = new Vector2(dc / 2, -oal);
            Vector2 v10 = new Vector2(-v9.X, v9.Y);
            Vector2 v11 = new Vector2(-v8.X, v8.Y);
            Vector2 v12 = new Vector2(-v7.X, v7.Y);
            Vector2 v13 = new Vector2(-v6.X, v6.Y);
            Vector2 v14 = new Vector2(-v5.X, v5.Y);
            Vector2 v15 = new Vector2(-v4.X, v4.Y);
            Vector2 v16 = new Vector2(-v3.X, v3.Y);
            Vector2 v17 = new Vector2(-v2.X, v2.Y);
            Vector2 v18 = new Vector2(-v1.X, v1.Y);
            Vector2 v19 = new Vector2(0, 2);
            Vector2 v20 = new Vector2(0, -oal - 2);
            Vector2 v21 = new Vector2(v9.X + prfrad * Math.Cos(pi / 2 - a1 - a2), v9.Y - prfrad * Math.Sin(pi / 2 - a1 - a2));
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            LwPolyline Arc8 = new LwPolyline();
            Arc8.Vertexes.Add(new LwPolylineVertex(v8));
            Arc8.Vertexes.Add(new LwPolylineVertex(v9));
            Arc8.Vertexes[0].Bulge = h * 2 / l;
            fun.PolyFill(dxf, Arc8, 0.5, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            LwPolyline Arc10 = new LwPolyline();
            Arc10.Vertexes.Add(new LwPolylineVertex(v10));
            Arc10.Vertexes.Add(new LwPolylineVertex(v11));
            Arc10.Vertexes[0].Bulge = h * 2 / l;
            fun.PolyFill(dxf, Arc10, 0.5, contour);
            Vector2[] Line11 = { v11, v12 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v12, v13 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, v17 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v17, v18 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v18, v1 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v19, v20 };
            fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
            Vector2[] Line20 = { v17, v2 };
            fun.drawBLine(dxf, Line20, 0.3, contour);
            Vector2[] Line21 = { v16, v3 };
            fun.drawBLine(dxf, Line21, 0.3, contour);
            Vector2[] Line22 = { v15, v4 };
            fun.drawBLine(dxf, Line22, 0.3, contour);
            Vector2[] Line23 = { v14, v5 };
            fun.drawBLine(dxf, Line23, 0.3, contour);
            Vector2[] Line24 = { v13, v6 };
            fun.drawBLine(dxf, Line24, 0.3, contour);
            Vector2[] Line25 = { v11, v8 };
            fun.drawBLine(dxf, Line25, 0.3, contour);
            Arc arc8 = new Arc(v21, prfrad, (pi / 2 + a2 - a1) / pi * 180, (pi / 2 + a1 + a2) / pi * 180);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v11, v8), -offset * 2 - apmx, 0, dimensionStyle);
            dim1.UserText = "DCX = " + Math.Round(dcx / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v10, v9), -offset, 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v9, v8), offset + (v8.X - v9.X) / 2, 270, dimensionStyle);
            dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v7.X - v3.X, 270, dimensionStyle);
            dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v9, v1), offset * 3 + 0.25 + v7.X - (v3.X + v9.X) / 2, 270, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v17, v2), offset + 0.5, 0, dimensionStyle);
            dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            RadialDimension dimrad7 = new RadialDimension(arc8, 135, offset / 2, dimensionStyle);//DimensionStyle.Default);
            dimrad7.UserText = "PRFRAD = " + Math.Round(prfrad / scale, 2);
            dxf.AddEntity(dimrad7);
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v15, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
            dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
            dxf.AddEntity(dim8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v7, v9), offset * 2 + (v7.X - v9.X) / 2, 270, dimensionStyle);
            dim9.UserText = "LH = " + Math.Round(lh / scale, 2);
            dxf.AddEntity(dim9);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void ThreadEndMill(Dictionary<string, Object> data) //直柄螺纹铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            string path = Convert.ToString(data["path"]);
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double tp = Convert.ToDouble(data["tp"]) * scale;
            string thft = Convert.ToString(data["thft"]);
            double bd = dc - tp;
            if (thft == "M60")
            {
                bd = dc - 3 / 8 * Math.Sqrt(3) * tp;
            }
            double isframe = Convert.ToDouble(data["isframe"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
            Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
            Vector2 v3 = new Vector2(v2.X, -ls);
            Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(pi / 4) / Math.Sin(pi / 4));
            Vector2 v5 = new Vector2(v4.X, -oal + lh + (dconms - dn) / 2 * Math.Cos(pi / 4) / Math.Sin(pi / 4));
            Vector2 v6 = new Vector2(bd / 2, -oal + lh);
            Vector2 v7 = new Vector2(v6.X, -oal + apmx);
            Vector2 v8 = new Vector2(v7.X, -oal);
            Vector2 v9 = new Vector2(dc / 4, -oal);
            Vector2 v10 = new Vector2(-v9.X, v9.Y);
            Vector2 v11 = new Vector2(-v8.X, v8.Y);
            Vector2 v12 = new Vector2(-v7.X, v7.Y);
            Vector2 v13 = new Vector2(-v6.X, v6.Y);
            Vector2 v14 = new Vector2(-v5.X, v5.Y);
            Vector2 v15 = new Vector2(-v4.X, v4.Y);
            Vector2 v16 = new Vector2(-v3.X, v3.Y);
            Vector2 v17 = new Vector2(-v2.X, v2.Y);
            Vector2 v18 = new Vector2(-v1.X, v1.Y);
            Vector2 v19 = new Vector2(0, 2);
            Vector2 v20 = new Vector2(0, -oal - 2);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.5, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.5, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawBLine(dxf, Line10, 0.5, contour);
            Vector2[] Line11 = { v11, v12 };
            fun.drawBLine(dxf, Line11, 0.5, contour);
            Vector2[] Line12 = { v12, v13 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, v17 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v17, v18 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v18, v1 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v19, v20 };
            fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
            Vector2[] Line20 = { v17, v2 };
            fun.drawBLine(dxf, Line20, 0.3, contour);
            Vector2[] Line21 = { v16, v3 };
            fun.drawBLine(dxf, Line21, 0.3, contour);
            Vector2[] Line22 = { v15, v4 };
            fun.drawBLine(dxf, Line22, 0.3, contour);
            Vector2[] Line23 = { v14, v5 };
            fun.drawBLine(dxf, Line23, 0.3, contour);
            Vector2[] Line24 = { v13, v6 };
            fun.drawBLine(dxf, Line24, 0.3, contour);
            Vector2[] Line25 = { v12, v7 };
            fun.drawBLine(dxf, Line25, 0.3, contour);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v6, v8), offset * 2 + (v3.X + v6.X) / 2 - v7.X, 270, dimensionStyle);
            dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v11, v8), -offset, 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v7, v8), offset + (v3.X + v6.X) / 2 - v7.X, 270, dimensionStyle);
            dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v7.X - (v3.X + v6.X) / 2, 270, dimensionStyle);
            dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            if (dconms >= dc)
            {
                LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 3 + (v2.X - v8.X) / 2 + 0.25, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
            }
            else
            {
                LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 3 + (v8.X - v2.X) / 2 + 0.25, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
            }
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v17, v2), offset + 0.5, 0, dimensionStyle);
            dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v15, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
            dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
            dxf.AddEntity(dim8);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void CuttingStylus(Dictionary<string, Object> data)  //直柄倒角铣刀
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            string path = Convert.ToString(data["path"]);
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double prfa = Convert.ToDouble(data["prfa"]) * pi / 180;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double isframe = Convert.ToDouble(data["isframe"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
            Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
            Vector2 v3 = new Vector2(v2.X, -ls);
            Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
            Vector2 v5 = new Vector2(v4.X, -oal + lh + (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
            Vector2 v6 = new Vector2(dc / 2, -oal + lh);
            Vector2 v7 = new Vector2(v6.X, -oal + apmx);
            Vector2 v8 = new Vector2(v7.X, -oal + dc / 2 / Math.Tan(prfa / 2));
            Vector2 v9 = new Vector2(0, -oal);
            Vector2 v10 = new Vector2(-v8.X, v8.Y);
            Vector2 v11 = new Vector2(-v7.X, v7.Y);
            Vector2 v12 = new Vector2(-v6.X, v6.Y);
            Vector2 v13 = new Vector2(-v5.X, v5.Y);
            Vector2 v14 = new Vector2(-v4.X, v4.Y);
            Vector2 v15 = new Vector2(-v3.X, v3.Y);
            Vector2 v16 = new Vector2(-v2.X, v2.Y);
            Vector2 v17 = new Vector2(-v1.X, v1.Y);
            Vector2 v18 = new Vector2(0, 2);
            Vector2 v19 = new Vector2(0, -oal - 2);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.5, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.5, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v11, v12 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v12, v13 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, v17 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v17, v1 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v16, v2 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v18, v19 };
            fun.drawPlinetype(dxf, Line19, 0.15, centre, Linetype.Center);
            Vector2[] Line20 = { v15, v3 };
            fun.drawBLine(dxf, Line20, 0.3, contour);
            Vector2[] Line21 = { v14, v4 };
            fun.drawBLine(dxf, Line21, 0.3, contour);
            Vector2[] Line22 = { v13, v5 };
            fun.drawBLine(dxf, Line22, 0.3, contour);
            Vector2[] Line23 = { v12, v6 };
            fun.drawBLine(dxf, Line23, 0.3, contour);
            Vector2[] Line24 = { v11, v7 };
            fun.drawBLine(dxf, Line24, 0.3, contour);
            Vector2[] Line25 = { v10, v8 };
            fun.drawBLine(dxf, Line25, 0.3, contour);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v6, v9), offset * 2 + (v3.X + v6.X) / 2 - v7.X + v6.X / 2, 270, dimensionStyle);
            dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v10, v8), -offset - (v8.Y - v9.Y), 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v7, v9), offset + (v3.X + v6.X) / 2 - v7.X + v8.X / 2, 270, dimensionStyle);
            dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v7.X - v3.X, 270, dimensionStyle);
            dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v9, v1), offset * 3 + 0.25 + v2.X / 2, 270, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v16, v2), offset + 0.5, 0, dimensionStyle);
            dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            Angular2LineDimension angdim7 = new Angular2LineDimension(new Line(v9, v10), new Line(v9, v8), offset, dimensionStyle);
            angdim7.UserText = "PRFA = " + Math.Round(prfa / (pi / 180), 2) + "°";
            dxf.AddEntity(angdim7);
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v14, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
            dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
            dxf.AddEntity(dim8);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void ThreadEndMillWithDrillingPart(Dictionary<string, Object> data)  //直柄带钻螺纹铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            string path = Convert.ToString(data["path"]);
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcd = Convert.ToDouble(data["dcd"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double prfa = Convert.ToDouble(data["prfa"]) * pi / 180;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double isframe = Convert.ToDouble(data["isframe"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
            Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
            Vector2 v3 = new Vector2(v2.X, -ls);
            Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
            Vector2 v5 = new Vector2(v4.X, -oal + lh + (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
            Vector2 v6 = new Vector2(dc / 2, -oal + lh);
            Vector2 v7 = new Vector2(v6.X, v6.Y - apmx);
            Vector2 v8 = new Vector2(dcd / 2, v7.Y);
            Vector2 v9 = new Vector2(v8.X, -oal + dcd / 2 / Math.Tan(prfa / 2));
            Vector2 v10 = new Vector2(0, -oal);
            Vector2 v11 = new Vector2(-v9.X, v9.Y);
            Vector2 v12 = new Vector2(-v8.X, v8.Y);
            Vector2 v13 = new Vector2(-v7.X, v7.Y);
            Vector2 v14 = new Vector2(-v6.X, v6.Y);
            Vector2 v15 = new Vector2(-v5.X, v5.Y);
            Vector2 v16 = new Vector2(-v4.X, v4.Y);
            Vector2 v17 = new Vector2(-v3.X, v3.Y);
            Vector2 v18 = new Vector2(-v2.X, v2.Y);
            Vector2 v19 = new Vector2(-v1.X, v1.Y);
            Vector2 v20 = new Vector2(0, 2);
            Vector2 v21 = new Vector2(0, -oal - 2);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.5, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.5, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.5, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.5, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawBLine(dxf, Line10, 0.5, contour);
            Vector2[] Line11 = { v11, v12 };
            fun.drawBLine(dxf, Line11, 0.5, contour);
            Vector2[] Line12 = { v12, v13 };
            fun.drawBLine(dxf, Line12, 0.5, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.5, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, v17 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v17, v18 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v18, v19 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v20, v21 };
            fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
            Vector2[] Line20 = { v19, v1 };
            fun.drawBLine(dxf, Line20, 0.3, contour);
            Vector2[] Line21 = { v18, v2 };
            fun.drawBLine(dxf, Line21, 0.3, contour);
            Vector2[] Line22 = { v17, v3 };
            fun.drawBLine(dxf, Line22, 0.3, contour);
            Vector2[] Line23 = { v16, v4 };
            fun.drawBLine(dxf, Line23, 0.3, contour);
            Vector2[] Line24 = { v15, v5 };
            fun.drawBLine(dxf, Line24, 0.3, contour);
            Vector2[] Line25 = { v14, v6 };
            fun.drawBLine(dxf, Line25, 0.3, contour);
            Vector2[] Line26 = { v13, v7 };
            fun.drawBLine(dxf, Line26, 0.3, contour);
            Vector2[] Line27 = { v11, v9 };
            fun.drawBLine(dxf, Line27, 0.3, contour);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.DimStyle(true);
            DimensionStyle dimensionStyle2 = fun.DimStyle(false);

            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v6, v10), offset * 2 + (v3.X + v8.X) / 2 - v8.X + v6.X / 2, 270, dimensionStyle);
            dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v14, v6), (v1.Y - v6.Y) / 2, 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v6, v8), offset + (v3.X + v8.X) / 2 - v8.X + (v8.X - v6.X) / 2, 270, dimensionStyle);
            dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v8.X - v3.X, 270, dimensionStyle);
            dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v10, v1), offset * 3 + 0.25 + v2.X / 2, 270, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v18, v2), offset + 0.5, 0, dimensionStyle);
            dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            Angular2LineDimension angdim7 = new Angular2LineDimension(new Line(v10, v11), new Line(v10, v9), offset, dimensionStyle2);
            angdim7.UserText = "PRFA = " + Math.Round(prfa / (pi / 180), 2) + "°";
            dxf.AddEntity(angdim7);
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v16, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
            dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
            dxf.AddEntity(dim8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v11, v9), -offset - (v9.Y - v10.Y), 0, dimensionStyle);
            dim9.UserText = "DCD = " + Math.Round(dcd / scale, 2);
            dxf.AddEntity(dim9);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
    }
}
